﻿/*
 *Author: Jeff Liu 
 *
 *Under MIT License
 *jebberwocky@gmail.com
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CtpGglMap.Core
{
    /// <summary>
    /// class for representing pixel x,y
    /// </summary>
    public class PixelXY
    {
        public PixelXY(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
        public int X { get; set; }
        public int Y { get; set; }

        /// <summary>
        /// using JSON representation {x,y} 
        /// e.g
        /// {x:1231, y:123}
        /// </summary>
        /// <returns>String</returns>
        public override string ToString()
        {
            return "{x:"+this.X+",y:"+this.Y+"}";
        }

        public override bool Equals(object obj)
        {
            if(obj ==null)
                return false;
            else if (obj == this)
                return true;
            else if (typeof(PixelXY) == obj.GetType())
            {
                PixelXY xy = obj as PixelXY;
                return xy.X == this.X && xy.Y == this.Y;
            }
            return false;
        }

        public override int GetHashCode()
        {
            int hash = 13;
            hash = (hash * 7) + this.X.GetHashCode();
            hash = (hash * 7) + this.Y.GetHashCode();
            return hash;
        }

        public static PixelXY UNDEFINED = new PixelXY(Int32.MaxValue, Int32.MaxValue);
    }
}
